Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

bugfix: Flex & Repeater fields not previewable #205

Merged
merged 9 commits into from
Jan 19, 2021

Conversation

jasonbahl
Copy link
Contributor

ACF stores revisions to fields in the meta of the revision. WPGraphQL attempts to resolve meta from the parent (published) post as WordPress core doesn't store revisions for meta. ACF does store revisions for ACF fields, so the WPGraphQL for ACF plugin currently is set to resolve ACF fields on revisions using the meta of the revision post.

There's currently a bug with nested fields of repeater and flex fields not properly resolving for revisions. This addresses that.

Before

Querying a Flex and Repeater field shows the same values for both the published post and the preview post:

Screen Shot 2021-01-14 at 1 38 38 PM

After

Querying a Flex and Repeater field shows the published values for the published post, and the preview values for the preview post:

Screen Shot 2021-01-14 at 1 37 56 PM

Copy link
Collaborator

@TylerBarnes TylerBarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and makes sense to me 👍
are you doing the tests as part of this PR or a separate one?

@jasonbahl
Copy link
Contributor Author

@TylerBarnes I was going to follow up with some tests later. They're a bit cumbersome to write for this case so I wanted to ship this to unblock folks first.

@tobiasandersen
Copy link

I applied this fix, but it didn't solve the issue. For what it's worth, the fix in #159 does solves my issue. Let me know if you need any other info or help testing.

@jasonbahl
Copy link
Contributor Author

@tobiasandersen can you share screenshots of your Post Edit screen with the data you're inputting, then show me screenshots of GraphiQL where you're querying the Published Post, and the Preview Post so I can see the difference.

If we make the change suggested in #159 it would break all other non-ACF meta, and this would be bad. It also wouldn't fix the issue of being able to preview ACF revisions.

I'd be happy to even hop on a Zoom or other video call to see what you're experiencing and see if we can get to the bottom of this.

@TylerBarnes
Copy link
Collaborator

Just tested this out and it seems to work well for me 👍 maybe this solves some of the problems but not all? If that's the case I vote we merge/ship this and then circle back on additional improvements (unless those other fixes can be made soon)

@TylerBarnes
Copy link
Collaborator

@tobiasandersen an export of your acf fields could be useful here too

@tobiasandersen
Copy link

I'm not sure what I did wrong last time, but when I was gonna reproduce it again now to show you, I wasn't able to. Sorry for the false alarm, this seems to fix my issues as well! Thanks @jasonbahl 🙏

@eliawk
Copy link

eliawk commented Sep 27, 2022

@jasonbahl as I've written in the #292, I still get null when using asPreview: true

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants